import java.io.FileNotFoundException;
import java.util.ArrayList;

/**
 *
 * @author Bjarni
 */
public class Disciplin implements DataObject{
    private String participantName;  
    private String disciplinDate;
    private int disciplinID; 
    private String disciplinType;
    private String disciplinResult;
    private String rally;

Disciplin(String participantName, String disciplinDate, int disciplinID, String disciplinType, String disciplinResult, String rally){
        this.participantName = participantName;
        this.disciplinDate = disciplinDate;
        this.disciplinID = disciplinID;
        this.disciplinType = disciplinType;
        this.disciplinResult = disciplinResult;
        this.rally = rally;
}
    
Disciplin(Member member, String disciplinDate, String disciplinType) throws FileNotFoundException{
        this.participantName = member.getFullName();
        this.disciplinDate = disciplinDate;
        this.disciplinID = assignDisciplinID();
        this.disciplinType = disciplinType;
        this.disciplinResult = "00:00:00";
        this.rally = "TRAINING";
        }

    @Override
    public String toString() {
        return participantName + ";" + disciplinDate + ";" + disciplinID + ";" + disciplinType + ";" + disciplinResult + ";" + rally;
    }

    public String getDisciplinDate() {
        return disciplinDate;
    }

    public int getDisciplinID() {
        return disciplinID;
    }

    public String getDisciplinType() {
        return disciplinType;
    }

    public String getParticipantName() {
        return participantName;
    }

    public void setDisciplinDate(String disciplinDate) {
        this.disciplinDate = disciplinDate;
    }

    public void setDisciplinType(String disciplinType) {
        this.disciplinType = disciplinType;
    }

    public String getDisciplinResult() {
        return disciplinResult;
    }

    public void setDisciplinResult(String disciplinResult) {
        this.disciplinResult = disciplinResult;
    }

    public String getRally() {
        return rally;
    }

    public void setRally(String rally) {
        this.rally = rally;
    }


    
    public int assignDisciplinID() throws FileNotFoundException{
        DisciplinList disciplinList = new DisciplinList();
        ArrayList<Disciplin> list = disciplinList.dataObjectToDisciplin(disciplinList.loadAllObjectsFromFile("Disciplins.xml"));
        if (list.isEmpty()){
            return 1;
        }
        else {
        return list.get(list.size() - 1).getDisciplinID() + 1;
        }
    }
}